package test.file;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

public class FileReadingActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Toast.makeText(this, "BEACH", Toast.LENGTH_SHORT).show();
        /*try {
			OutputStream out = openFileOutput("WOLVERINE.txt", 0);
			if (out!=null) {
				BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
				writer.write("SILLY PIGS\n"+
"LOVE EAGLES\n"+
"IN THEIR\n"+
"CAT HAIR\n"+
"ENTRAILS\n");
				writer.close();
			}
			out.close();
		} catch (Exception e) {
			Toast.makeText(this, "BEAGLE", Toast.LENGTH_SHORT).show();
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
        /**/try {
			InputStream in = openFileInput("WOLVERINE.txt");
			if (in!=null) {
				BufferedReader reader = new BufferedReader(new InputStreamReader(in));
				String curLine, ans="";
				while ((curLine=reader.readLine())!=null) {
					ans+=curLine.substring(0,1);
				}
				Toast.makeText(this, (CharSequence) ans, Toast.LENGTH_LONG).show();
			} else {
				Toast.makeText(this, (CharSequence) "THERE AIN'T NO FILE, HOOLIGAN!", Toast.LENGTH_LONG).show();
			}
			in.close();
		} catch (Exception e) {
	        Toast.makeText(this, "CRABS", Toast.LENGTH_SHORT).show();
			// TODO Auto-generated catch block
	        System.out.println(e.getClass());
			e.printStackTrace();
		}
        
    }
}